package wql.aaa.controller;

import com.aaa.entity.TbZone;
import com.aaa.vo.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import wql.aaa.service.ZoneService;
import wql.aaa.vo.SearchFormData;

import javax.swing.plaf.PanelUI;

/**
 * @author wql
 * @version 1.0
 * @date 2023/2/27 17:41
 */
@RestController
@RequestMapping("/home/zone")
public class ZoneController {

    @Autowired
    private ZoneService zoneService;

    @PostMapping("/fuzzySearch/{currentPage}/{pageSize}")
    public Result queryAll(@PathVariable Integer currentPage, @PathVariable Integer pageSize, @RequestBody SearchFormData searchFormData) {
        System.out.println("searchFormData = " + searchFormData);
        return zoneService.queryAll(currentPage, pageSize, searchFormData);
    }


    @PostMapping("/updateDisable")
    public Result updateDisabled(@RequestBody TbZone tbZone) {
        return zoneService.updateIsDisable(tbZone);
    }

    @PostMapping("/insertPrefecture")
    public Result add(@RequestBody TbZone tbZone) {
        return zoneService.addZone(tbZone);
    }

    @GetMapping("/removePrefecture/{id}")
    public Result deleteByZoneId(@PathVariable String id) {
        return zoneService.deleteByZoneId(id);
    }

    @PostMapping("/updatePrefecture")
    public Result updateZone(@RequestBody TbZone tbZone) {
        return zoneService.updateZone(tbZone);
    }


    @PostMapping("/code/{isDisable}/{id}")
    public Result code(@PathVariable Integer isDisable, @PathVariable String id) {
        return zoneService.code(isDisable, id);
    }


}
